#include<bits/stdc++.h>
#include<algorithm>

using namespace std;

const int maxn = 100000;
int counts = 0;

//the num of candidate
int n;

// 及格分
int L;
//the H score of talent and ethics
int H;

struct Student{
    char id[10];
    int talent;
    int ethics;
    int sum; 
    int level; 
}canditate[maxn];

bool cmp(Student a ,Student b)
{
    //类别小的在前边
    if(a.level != b.level) return a.level < b.level;
    // 类别相同时，总分大的在前
    else if(a.sum != b.sum) return a.sum > b.sum;
    // 总分相同时，得分大的在前
    else if(a.ethics != b.ethics) return a.ethics > b.ethics;
    else return strcmp(a.id,b.id)< 0;
}

int main()
{
    scanf("%d%d%d",&n,&L,&H);
    // cout << n << " " << h_ethics << " " << h_talent;
    // m为及格的人数
    int m = n;
    for (int i = 0; i < n; i++)
    {
        scanf("%s%d%d",canditate[i].id,&canditate[i].ethics,&canditate[i].talent);
        // cout << canditate[i].ethics << " " << canditate[i].talent;
        canditate[i].sum = canditate[i].ethics + canditate[i].talent;
        // 先把不及格的设为等级5
        if(canditate[i].ethics < L || canditate[i].talent < L)
        {
            canditate[i].level = 5;
            m--;
        }
        else if (canditate[i].ethics >= H && canditate[i].talent >= H) canditate[i].level = 1;
        else if (canditate[i].ethics >= H && canditate[i].talent < H) canditate[i].level = 2;
        else if (canditate[i].ethics < H && canditate[i].talent < H &&canditate[i].ethics >= canditate[i].talent) canditate[i].level = 3;
        else canditate[i].level = 4;
    }
    sort(canditate,canditate+n,cmp);
    printf("%d\n",m);
    for (int i = 0; i < m; i++)
    {   
        // cout << canditate[i].id << " " << canditate[i].ethics << " " << canditate[i].talent << endl;
        printf("%s %d %d\n",canditate[i].id,canditate[i].ethics,canditate[i].talent);
    }
    
    
    
    return 0;
}